import { useEffect, useState } from "react";
import { loadUserInfoAPI } from "../services/user";
import { dalImg } from "../utils/tools";

function useUser() {
  const [userInfo, setUserInfo] = useState({});

  useEffect(() => {
    loadUserInfoAPI().then((res) => {
      setUserInfo({ ...res.data, avatar: dalImg(res.data.avatar) });
    });
  }, []);

  return {
    userInfo,
  };
}

export default useUser;
